// import 'es6-promise';
import Vue from 'vue'
import router from './router';
import App from './App.vue'
import store from './store'
import {
	Field,
	Button,
	Form,
	Grid,
	GridItem,
	NavBar,
	icon,
	Toast,
	Row,
	Col,
	Calendar,
	Divider,
	ContactCard,
	Checkbox,
	Popup,
	Dialog,
	ActionSheet,
	Cell,
	CellGroup,
	Image,
	Picker,
	DatetimePicker,
	Empty,
	Notify
} from 'vant';

import ajax from '@/utils/request'

import {i18n, vantLocales} from '@js/lang'

import '@/assets/js/rem'
import config from '../package.json'

Vue.prototype.version =  config.version
Vue.prototype.hideHeader = '46px'
const engCNHtml=(that,v)=>that.$t('app.'+that.$route.name+'.'+v).indexOf('app.')>-1?'':that.$t('app.'+that.$route.name+'.'+v);
Vue.prototype.$H=engCNHtml
Vue.prototype._fixStyleHeiht = ($route) => {
	// console.log('8888', $route)
	return {
		height: 'calc(100vh - ' + ($route.meta.hideHeader || Vue.prototype.hideHeader) + ')'
	}
}
// console.log('flexible',window)
// flexible()
// Vue.use(Mui)
//自动化全局注册基础组件过程结束

Vue.prototype.$ajax = ajax
// Vue.use(NavBar)
Vue.use(Field).use(Button).use(Field).use(NavBar).use(Grid).use(icon).use(GridItem).use(Calendar).use(Form).use(ContactCard).use(Row).use(Col).use(Divider).use(Popup).use(Checkbox).use(Dialog).use(ActionSheet).use(Cell).use(CellGroup).use(Image).use(Notify).use(Toast)
.use(DatetimePicker).use(Picker).use(Empty)

const filterName = function(list, keyObj, str = ' ') {
//console.log("dsfds",list,keyObj,str)
if (typeof(list) === 'object') {
		if (keyObj&&typeof(keyObj) === 'object') {
			for (var i in keyObj) {
				str = list[keyObj[i]]+str
			}
				console.log("dfstr ",str)
		} else {
			str = list['lastName'] + str + list['firstName'] + str + list['tcName']
		
		}
		return str
	} else {
		return '-'
	}
}
Vue.prototype.filterName= filterName
Vue.filter('$H', engCNHtml)
Vue.filter('FilterName', filterName)
const FilterStausClor =(e)=>{
	var colrAct='green',colr='Grey',clorCompleted='Orange'

	colr= e==='ACTIVE'?colrAct:e==='COMPLETED'?clorCompleted:colr
	console.log("ds",colr,e)
	return colr
}
Vue.prototype.imgURL=process.env.BASE_URL
Vue.prototype.env = process.env
console.log('手打',process)
// 导入资源文件

console.log('当前的语言是：', i18n.messages[i18n.locale].app.hello,i18n.locale)
// vant-ui组件国际化
vantLocales(i18n.locale)
Vue.prototype.$vantLocales=vantLocales
Vue.filter('FilterStausClor', FilterStausClor)
Vue.prototype.FilterStausClor=FilterStausClor

Vue.prototype.back = function () {
  if (window.history.length > 1) {
    this.$router.back()
  } else {
    this.$router.push('/')
  }
}
new Vue({
	el: '#app',
	router,
	i18n,
	store,
	render: (h) => h(App)
})
